<?php
require('core.php');
?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <?php
    $config = Model('setting')->getListSetting();
    ?>
    <title><?php echo $config['site_name'] ?></title>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="full-screen" content="yes"/>
    <meta name="browsermode" content="application"/>
    <!-- QQ强制竖屏 QQ强制全屏 -->
    <meta name="x5-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="x5-page-mode" content="app"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>

    <!-- <link rel="stylesheet" type="text/css" href="/wap/e_tpl/css/new.css"> -->
    <style>
        header {
            background: #f8f8f8;
            height: 60px;
        }

        #bottom .nav {
            background: #444
        }

        .header-wrap {
            background: #f8f8f8;
        }

        .header-inp {
            display: block;
            margin: 10px 5px;
            border: 1px solid #ccc;
            border-radius: 5px;
            height: 42px;
        }

        .header-inp .icon {
            float: left;
            vertical-align: top;
            width: 32px;
            height: 32px;
            margin: 7px 5px;
            background-image: url(/wap/e_tpl/images/search_ico.png);
            background-repeat: no-repeat;
            background-position: 50% 50%;
            background-size: 70%;
            opacity: 0.3;
        }

        .search-input {
            color: #666;
        }
    </style>
</head>
<body>
<?php
$first_pic = @include(BASE_DATA_PATH . '/mobile/config.php');
if (!empty($first_pic['pic']) && $first_pic['open_first_pic'] == 1) {
    ?>
    <script>
        if (window.sessionStorage.show_pic == 1) {
            document.write("<style>#first_pic{display: none !important;} body{overflow: auto !important;}</style>")
        }
    </script>
    <style>
        body {
            overflow: hidden;
        }

        #first_pic {
            width: 100% !important;
            height: 100% !important;
            background-size: cover;
            z-index:100000000000000000000000;
        }
    </style>
    <div id="first_pic"
         style="position: fixed;background-image: url(<?php echo $first_pic['pic'] ?>);z-index: 10000;overflow: hidden;background-repeat: no-repeat;background-size: 100% 100%;">

    </div>
    <script>
        $('#first_pic').css({
            height: $(window).height()
        }).click(function () {
            $(this).fadeOut();
            $('body').css({
                overflow: 'auto'
            })
            window.sessionStorage['show_pic'] = 1;
        });

        setTimeout(function () {
            $('#first_pic').trigger('click');
        }, 3000)

    </script>
    <?php
}
?>

<header class="main">
    <div class="header-wrap">
        <div class="header-wrap">
            <a href="tmpl/search.php" class="header-inp"> <i class="icon"></i> <span class="search-input" id="keyword">请输入关键词</span>
            </a>
        </div>
    </div>
</header>
<style>
    .nctouch-home-nav {
        background-color: #FFF;
        position: relative;
        z-index: 0;
        border-bottom: solid 0.05rem #EEE;
    }

    .fixed-Width {
        min-width: 320px;
        max-width: 640px;
        margin: 0 auto;
    }

    .nctouch-home-nav {
        margin-top: 40px;
    }

    .nctouch-home-nav ul {
        font-size: 0;
        overflow: hidden;
    }

    .nctouch-home-nav li {
        float: left;
        width: 25%;
        height: 100px;
        padding: 10px 0 8px 0;
    }

    .nctouch-home-nav li a {
        display: block;
        text-align: center;
    }

    .nctouch-home-nav li:nth-child(1) span {
        background-color: #FB6E52;
    }

    .nctouch-home-nav li:nth-child(2) span {
        background-color: #48CFAE;
    }

    .nctouch-home-nav li:nth-child(3) span {
        background-color: #4FC0E8;
    }

    .nctouch-home-nav li:nth-child(4) span {
        background-color: #AC92ED;
    }

    .nctouch-home-nav li span {
        display: inline-block;
        width: 60px;
        height: 60px;
        margin: 0 auto 0.3rem auto;
        border-radius: 100%;
    }

    .nctouch-home-nav li:nth-child(1) span i {
        background-image: url(/wap/e_tpl/images/browse_list_w.png);
    }

    .nctouch-home-nav li p {
        display: block;
        font-size: 16px;
        line-height: 16px;
        color: #555;
    }

    .nctouch-home-nav li:nth-child(2) span i {
        background-image: url(/wap/e_tpl/images/cart_w.png);
    }

    .nctouch-home-nav li:nth-child(3) span i {
        background-image: url(/wap/e_tpl/images/member_w.png);
    }

    .nctouch-home-nav li:nth-child(4) span i {
        background-image: url(/wap/e_tpl/images/mcc_04_w.png);
    }

    .nctouch-home-nav li span i {
        display: block;
        width: 100%;
        height: 100%;
        background-position: 50% 50%;
        background-repeat: no-repeat;
        background-size: 50%;
    }
</style>
<?php
if ($first_pic['open_icons'] == 1) {

    ?>
    <div class="nctouch-home-nav fixed-Width" style="margin-top: 0;padding-top: 0;margin-bottom: 0;">
        <ul style="padding: 0;">
            <?php
            if (!isset($first_pic)) {
                $first_pic = array();
            }
            for ($i = 0; $i < 4; $i++) {

                ?>
                <li><a href="<?php echo $first_pic['link'][$i] ?>"><span style="background: none;">
					  <img src="<?php echo $first_pic['pics'][$i] ?>"
                           style="width: 60px;height: 60px;border:0;border-radius:60px" alt="">
				  </span>

                        <p><?php echo $first_pic['text'][$i] ?></p>
                    </a></li>
                <?php
            }
            ?>

        </ul>
    </div>
    <?php
}
?>
<div id="header_faker"></div>
<div class="main" id="main-container"></div>
<footer id="footer"></footer>
<script type="text/html" id="adv_list">
    <div class="adv_list">
        <div class="swipe-wrap">
            <% for (var i in item) { %>
            <div class="item">
                <a href="<%= item[i].url %>">
                    <img src="<%= item[i].image %>" alt="">
                </a>
            </div>
            <% } %>
        </div>
    </div>
</script>
<script type="text/html" id="home1">
    <div class="index_block home1">
        <% if (title) { %>
        <div class="title"><%= title %></div>
        <% } %>
        <div class="content">
            <div class="item">
                <a href="<%= url %>">
                    <img src="<%= image %>" alt="">
                </a>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="home2">
    <div class="index_block home2">
        <% if (title) { %>
        <div class="title"><%= title %></div>
        <% } %>
        <div class="content">
            <div class="item home2_1">
                <a href="<%= square_url %>"><img src="<%= square_image %>" alt=""></a>
            </div>
            <div class="item home2_2">
                <div class="border-left">
                    <div class="border-bottom">
                        <a href="<%= rectangle1_url %>"><img src="<%= rectangle1_image %>" alt=""></a>
                    </div>
                    <div>
                        <a href="<%= rectangle2_url %>"><img src="<%= rectangle2_image %>" alt=""></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="home3">
    <div class="index_block home3">
        <% if (title) { %>
        <div class="title"><%= title %></div>
        <% } %>
        <div class="content">
            <% for (var i in item) { %>
            <div class="item">
                <a href="<%= item[i].url %>"><img src="<%= item[i].image %>" alt=""></a>
            </div>
            <% } %>
        </div>
    </div>
</script>
<script type="text/html" id="home4">
    <div class="index_block home2">
        <% if (title) { %>
        <div class="title"><%= title %></div>
        <% } %>
        <div class="content">
            <div class="item home2_2">
                <div class="border-right">
                    <div class="border-bottom">
                        <a href="<%= rectangle1_url %>"><img src="<%= rectangle1_image %>" alt=""></a>
                    </div>
                    <div>
                        <a href="<%= rectangle2_url %>"><img src="<%= rectangle2_image %>" alt=""></a>
                    </div>
                </div>
            </div>
            <div class="item home2_1">
                <a href="<%= square_url %>"><img src="<%= square_image %>" alt=""></a>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="goods">
    <div class="index_block goods">
        <% if (title) { %>
        <div class="title"><%= title %></div>
        <% } %>
        <div class="content">
            <% for (var i in item) { %>
            <div class="goods-item">
                <a href="tmpl/product_detail.html?goods_id=<%= item[i].goods_id %>">
                    <div class="goods-item-pic"><img src="<%= item[i].goods_image %>" alt=""></div>
                    <div class="goods-item-name"><%= item[i].goods_name %></div>
                    <div class="goods-item-price">
                        ￥<%= item[i].goods_promotion_price %>
                        <div class='ext'>
                            <% if (item[i].open_tax == 1) { %>
                            <span class='ext'>保税</span>
                            <% } %>
                            <% if (item[i].is_own == 1) { %>
                            <span class='ext'>自营</span>
                            <% } %>
                        </div>

                    </div>
                </a>
            </div>
            <% } %>
        </div>
    </div>
</script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/template.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/swipe.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/tmpl/footer.js"></script>
<?php

//	require(dirname(BASE_PATH) . '/wap/wechat_core.php');
?>
<script>
    wx.ready(function () {
        // alert(3);
        // wx.checkJsApi({
        //     jsApiList: ['chooseImage'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
        //     success: function(res) {
        //     	// alert(JSON.stringify(res))
        //         // 以键值对的形式返回，可用的api值true，不可用为false
        //         // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
        //     }
        // });
    });

</script>

<script>
    var timer = setInterval(function () {
        if ($('.goods-item-pic img').length) {
            $('.goods-item-pic img').each(function () {
                $(this).height($(this).width());
            });
            $('body').css('overflow-x', 'hidden');
            clearInterval(timer);
        }
    }, 10);
</script>



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?7438c324d63aadd6378544501f8e4643";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>


</body>
</html>
<script>
    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    //只有是微信访问的情况下，以下设置才生效
    if (strpos($user_agent, 'MicroMessenger') !== false) {
    if(!isset($_COOKIE['key'])){
    require_once(dirname(BASE_PATH) . '/wxpay/lib/WxPay.Api.php');

    $js = new JsApiPay();
    $open_id = $js->GetOpenid();
    if ($member_info = Model()->table('member')->where(array('wechat_openid' => $open_id))->find()) {

    $token = _get_token($member_info['member_id'], $member_info['member_name'], 'wap');
    ?>
    addcookie('key', '<?php echo $token;?>');
    location.href = '<?php echo urldecode($_GET['ref'])?>';
    //                if(<?php //echo empty($_SERVER['HTTP_REFERER']) ? 'true' : 'false'?>//){
    //                    location.href = '<?php //echo $_SERVER['HTTP_REFERER']?>//'
    //                }
    //                else if(localStorage.ref) {
    //                    location.href = ref;
    //                }
    //                else{
    //                    location.href = '/wap/tmpl/member/member.php';
    //                }
</script>
<?php
exit;
}
else {

?>
<script>

    layer.open({
        title: false,
        shadeClose: false,
        content: '系统检测到您还未绑定微信',
        btn: ['直接登录', '绑定账号'],
        yes: function (index) {
            layer.close(index);
            location.href = '/wap/jssdk/wechat_login.php?open_id=<?php echo $open_id ?>&ref=<?php echo $_GET['ref'] ?>';
        },
        no: function (index) {
            layer.close(index);
            $.post('/shop/?act=seccode&op=write_session', {key: 'bind_wechat', value: 1}, function () {
                $('#loginbtn').html('绑定已有账号')
            });
        }
    });

    <?php }
    }
    } ?>
</script>